﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;

namespace RMS.Utils.DatabaseSchema
{
    public abstract class SchemaParser
    {
        // Fields
        private DbConnection _connection;
        protected List<Table> _tables;
        public List<Table> Tables
        {
            get
            {
                if (_tables.Count == 0)
                    this.ParseTables();
                return this._tables;
            }
        }
        protected List<View> _views;
        public List<View> Views
        {
            get
            {
                if (_views.Count == 0)
                    this.ParseView();
                return this._views;
            }
        }
        // Methods
        public SchemaParser()
        {
        }

        public SchemaParser(DbConnection connection)
        {
            this._connection = connection;
            this._tables = new List<Table>();
            this._views = new List<View>();
        }
        protected abstract void ParseTables();
        protected abstract void ParseView();
        public DbConnection Connection
        {
            get
            {
                return this._connection;
            }
            set
            {
                this._connection = value;
            }
        }


    }
}
